package com.cms.work.core;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class SimpleResponse implements Serializable{
	
	private static final long serialVersionUID = 5124924321964515140L;
	private int state;
	private int code;
	private String msg;
	private Map<String,Object> data; //默认为hashMap,也可为对象
	
	public enum StateEnum {
		
		SUCCESS(1),ERROR(2),UNSIGN(3);
		
		private int value;
		private StateEnum(int value){
			this.value = value;
		}
		public int getValue(){
			return this.value;
		}
	}
	
	public SimpleResponse() {}
	
	public SimpleResponse(int state) {
		this.state = state;
	}
	
	public SimpleResponse(int state, String msg) {
		this.state = state;
		this.msg = msg;
	}
	
	public SimpleResponse(int state, String msg, Map<String,Object> data) {
		this.state = state;
		this.msg = msg;
		this.data = data;
	}
	
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Map<String,Object> getData() {
		return data;
	}
	public void setData(Map<String,Object> data) {
		this.data = data;
	}
	
	public void putData(String key,Object value){
		if( this. data == null ){
			this.data = new HashMap<String,Object>();
		} 
		this.data.put(key, value);
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}
}
